# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=dmake

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=4.12.2
pkgrel=2
pkgdesc="Dmake is a make utility similar to GNU make or the Workshop dmake (mingw-w64)"
arch=('any')
groups=("${MINGW_PACKAGE_PREFIX}")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs' 'strip')
license=('GPL')
url="https://code.google.com/a/apache-extras.org/p/dmake/"
source=("http://dmake.apache-extras.org.codespot.com/files/dmake-${pkgver}.tar.bz2"
        "dmake-mingw.patch")
md5sums=('9194f727c31d1db18bf5dd02e7b2dd09'
         'a39a65958762b2877c994428978d0c3d')

prepare() {
  cd ${srcdir}/dmake-${pkgver}
  patch -p1 -i ${srcdir}/dmake-mingw.patch
}

build() {
  unset SHELL
  mkdir -p ${srcdir}/build-${CARCH} && cd ${srcdir}/build-${CARCH}
  MSYSTEM=MINGW ../dmake-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST}
  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  make DESTDIR="${pkgdir}" install
  mv "${pkgdir}${MINGW_PREFIX}/share/startup" "${pkgdir}${MINGW_PREFIX}/bin"
}
